from course import models
from rest_framework import serializers


class DirectionSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.Direction
        fields = '__all__'


class CateSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.Cate
        fields = '__all__'



class CourseSerializer(serializers.ModelSerializer):
    # tea=serializers.SerializerMethodField(read_only=True)# 自定义字段  read_only=True表示只读  会调用对应的方法
    # def get_tea(self,obj): # 自定义方法
    #     return {'name':obj.teacher.name,'job':obj.teacher.job,'img':obj.teacher.img,'intro':obj.teacher.intro}
    class Meta:
        model = models.Course
        fields = '__all__'
        depth = 1


class TeacherSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.Teacher
        fields = '__all__'


class LevelSerializer(serializers.ModelSerializer):
    class Meta:
        model = models.Level
        fields = '__all__'